import matplotlib.pyplot as plt
import pandas as pd
import numpy as np

n_values = [1]
plt.figure(figsize=(10, 8))

for n in n_values:
    try:
        data = pd.read_csv(f'data.csv', header=None)
        plt.plot(data.to_numpy()[:, 0], data.to_numpy()[:, 1], label=f'speed', marker='o')  # 转换为 NumPy 数组
    except FileNotFoundError:
        print(f"File data.csv not found.")
    except Exception as e:
        print(f"An error occurred while processing data.csv: {e}")


# 添加图例和标签
plt.legend()
plt.title('V t')
plt.xlabel('time')
plt.ylabel('speed')
plt.grid(True)

# 保存图像
plt.savefig('speed.png')

plt.show()
